package com.newtouch.xcd.cms.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.newtouch.xcd.cms.entity.Product;
import com.newtouch.xcd.cms.mapper.ProductMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.newtouch.xcd.cms.service.ProductService;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author dongyuefeng
 * @since 2020-06-21
 */
@Service
@Component
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Override
    public Product queryByName(String name){

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("name",name);
        List<Product> products=this.list(queryWrapper);
        if(CollUtil.isEmpty(products))
        {
            return null;
        }
        else
        {
            return products.get(0);
        }
    }

}
